package com.web.common.tool;

import java.util.Random;

public class RandomString {
	
	private static final String TEMPLATE_CHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
	
	private static Random random = new Random();

	private RandomString() {}
	
	/**
	 * 获取字随机符串
	 * @param len 输出字符串长度
	 * @return String 输出的字符串
	 *
	 * @author zhouhui
	 * @since 2023.12.08 
	 */
	public static String getText(int len) {
		StringBuilder strBuilder = new StringBuilder();
		for(int i = 0; i < len; i++) {
			int beginIndex = random.nextInt(TEMPLATE_CHAR.length());
			strBuilder.append(TEMPLATE_CHAR.substring(beginIndex, beginIndex+1));
		}
		return strBuilder.toString();
	}
}
